package com.example.hms.controller;

import com.example.hms.entity.Customer;
import com.example.hms.service.CustomerService;
import com.example.hms.util.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/customer")
public class CustomerController {
    // 注入 CustomerService 服务，用于处理客户相关的业务逻辑
        @Resource
        private CustomerService customerService;

        // 处理查询所有客户的请求，可以按客户名、电话号码和身份证号进行筛选
        @RequestMapping(value = "selectAllCustomer", method = RequestMethod.GET)
        public Result selectAllCustomer(String customerName, String phoneNumber, String identificationCard) {
            return customerService.selectAllCustomer(customerName, phoneNumber, identificationCard);
        }

        // 处理添加新客户的请求
        @RequestMapping(value = "insert", method = RequestMethod.GET)
        public Result insert(Customer customer, HttpServletRequest request) {
            return customerService.insert(customer,request);
        }

        // 处理更新客户信息的请求
        @RequestMapping(value = "update", method = RequestMethod.GET)
        public Result update(Customer customer, HttpServletRequest request) {
            return customerService.update(customer,request);
        }

}
